package com.ma4567.remotecontroller.LoginRequest;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ma4567.remotecontroller.RemoteControllerApplication;
import org.springframework.web.bind.annotation.*;

class tryStoredCookieResponse extends com.ma4567.remotecontroller.util.CustomRespone{
    public tryStoredCookieResponse(int status) {
        super(status);
    }
}


@CrossOrigin
@RestController
public class TryCookie {
    @RequestMapping(value = "/api/tryStoredCookie", method = RequestMethod.GET)
    public String tryStoredCookie (@RequestParam("cookie") String cookie){
        System.out.println(cookie + " try identify stored cookie");
        if(!RemoteControllerApplication.userManager.JudgeCookie(cookie)){//鉴权
            return JSONObject.toJSONString(new tryStoredCookieResponse(1), SerializerFeature.PrettyFormat);
        }
        else {
            return JSONObject.toJSONString(new tryStoredCookieResponse(0), SerializerFeature.PrettyFormat);
        }
    }
}
